package com.sbhotel.chotellauncher.widget;

import android.app.Dialog;
import android.content.Context;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.view.Window;
import android.view.WindowManager;

import com.sbhotel.chotellauncher.R;

public class WifiConnectDialog extends Dialog {
    public WifiConnectDialog(@NonNull Context context) {
        super(context);
    }

    public WifiConnectDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected WifiConnectDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_wifi_connect);

        //initView();
        //initData();

        //按空白处不能取消动画
        setCanceledOnTouchOutside(false);
        //setCancelable(false);
        //设置window背景，默认的背景会有Padding值，不能全屏。当然不一定要是透明，你可以设置其他背景，替换默认的背景即可。
        //getWindow().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.black_trans_90)));
        //一定要在setContentView之后调用，否则无效
        //getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        //getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

        getWindow().getDecorView().setPadding(0, 0, 0, 0);
        getWindow().getDecorView().setBackground(ContextCompat.getDrawable(getContext(), R.mipmap.background));
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
                PixelFormat.TRANSLUCENT);

        getWindow().setAttributes(params);
    }
}
